package com.example.shengyin.frontController;

import com.example.shengyin.entity.Attach;
import com.example.shengyin.service.AttachService;
import com.example.shengyin.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/front/attach")
@Validated
@CrossOrigin(origins = "*", maxAge = 3600,allowCredentials="true")
@Api(tags = "CarouselFrontController",description = "轮播图")
//@Validated
//@CrossOrigin(origins = "*", maxAge = 3600,allowCredentials="true")
//@Api("前端附件attach接口")
public class CarouselFrontController {
    @Autowired
    private AttachService attachService;

    @PostMapping("/give")
    @ApiOperation("根据carousel查地址" +
            "首页：index\n" +
            "媒体报道：Media_coverage\n" +
            "交流合作：Cooperation\n" +
            "联系我们：Contact_Us\n" +
            "服务群体：Service_group\n" +
            "专家团队：Expert_team\n" +
            "课程介绍：Course_Introduction\n" +
            "公司新闻：Company_News\n" +
            "活动讲座：Activity_Lectures\n" +
            "言语科普：Speech_Science\n" +
            "媒体视频：Media_Video\n" +
            "企业活动：Corporate_activities\n" +
            "品牌宣传：Brand_promotion\n" +
            "家庭训练技巧：House_training\n" +
            "朗朗SPEECH：SPEECH\n" +
            "成功案例：successful_case\n" +
            "STAR课程：STAR_CLASS\n")
    public Result give(@ApiParam(name = "carousel", value = "轮播板块") @RequestParam(required = false)String carousel){
        List<String> give = attachService.give(carousel);
        return give==null?Result.success("无"):Result.success(give);
    }
    @GetMapping("/findCarouseel")
    @ApiOperation("查找所有轮播位置")
    public Result findCarouseel(){
        List<String> carouseel = attachService.findCarouseel();
        return carouseel==null?Result.error("无"):Result.success(carouseel);
    }

}
